﻿using System.Collections.Generic;
using System.Threading.Tasks;
using YiSha.Entity.Test;
using YiSha.Model.Param.Test;
using YiSha.Service.Test;
using YiSha.Util.Model;

namespace YiSha.Business.Test
{
    public class ProcessBLL
    {

        private readonly ProcessService processService = new ProcessService();

        #region 获取数据
        public async Task<TData<List<ProcessEntity>>> GetListJson(ProcessParam param)
        {

            List<ProcessEntity> processEntities = await processService.GetListJson(param);

            TData<List<ProcessEntity>> obj = new TData<List<ProcessEntity>>
            {
                Data = processEntities,
                Tag = 1
            };
            return obj;
        }

        public async Task<TData<List<ProcessEntity>>> GetListJsonByUserId(long? userId)
        {

            //遍历权限列表，查询有权限的工序
            ProcessParam processParam = new ProcessParam
            {
                UserId = userId
            };

            List<ProcessEntity> processEntities = await processService.GetListJson(processParam);

            TData<List<ProcessEntity>> obj = new TData<List<ProcessEntity>>
            {
                Data = processEntities,
                Tag = 1
            };
            return obj;
        }

        public async Task<TData<List<ProcessEntity>>> GetListJsonByDepartmentRemark(string departmentRemark)
        {

            //遍历权限列表，查询有权限的非顶级工序
            ProcessParam processParam = new ProcessParam
            {
                DepartmentRemark = departmentRemark,
                ParentId = 0,
                ParentIdIsEqual = false,//false表示希望匹配ParentId非0的记录
            };

            List<ProcessEntity> processEntities = await processService.GetListJson(processParam);

            TData<List<ProcessEntity>> obj = new TData<List<ProcessEntity>>
            {
                Data = processEntities,
                Tag = 1
            };
            return obj;
        }
        #endregion

        #region 新增数据
        public async Task<int> Add(ProcessEntity processEntity)
        {
            return await processService.Add(processEntity);
        }
        #endregion

    }
}
